// 导入网络请求库
import axios from '../utils/request'

// 声明常量记录服务器地址
import {HOST_URL} from '../config/host'

// 获取用户的token
let token:string | null | any  = localStorage.getItem('AUTO_TOKEN')

// 1.0 管理员登录
// http://127.0.0.1:3000/admin/login
export const loginFunc = (data={})=> {
    return axios.post(`${HOST_URL}/admin/login`,data)
}
// 2.0 删除图片
// http://127.0.0.1:3000/photo/delete
export const removePhotoFunc = (data={})=>{
    return axios.post(`${HOST_URL}/photo/delete`,data)
}
// 3.0 发布轮播图
// http://127.0.0.1:3000/banner/add
export const addBannerFunc = (data={})=>{
    return axios.post(`${HOST_URL}/banner/add`,data,{headers:{token}})
}
// 4.0 轮播图列表
// http://127.0.0.1:3000/banner/list
export const listBannerFunc = (data={})=>{
    return axios.get(`${HOST_URL}/banner/list`,{params: data , headers:{token}})
}
// 5.0 删除轮播图
// http://127.0.0.1:3000/banner/remove
export const removeBannerFunc = (data={})=>{
    return axios.post(`${HOST_URL}/banner/remove`,data,{headers:{token}})
}
// 6.0 获取导航列表
// http://127.0.0.1:3000/navs/list
export const listNavFunc = (data={})=>{
    return axios.get(`${HOST_URL}/navs/list`,{params: data , headers:{token}})
}

// 7.0 添加导航
// http://127.0.0.1:3000/navs/add
export const addNavFunc = (data={})=>{
    return axios.post(`${HOST_URL}/navs/add`,data,{headers:{token}})
}

// 8.0 删除导航
// http://127.0.0.1:3000/navs/remove
export const removeNavFunc = (data={})=>{
    return axios.post(`${HOST_URL}/navs/remove`,data,{headers:{token}})
}


// 9.0 编辑导航
// http://127.0.0.1:3000/navs/edit
export const editNavFunc = (data={})=>{
    return axios.post(`${HOST_URL}/navs/edit`,data,{headers:{token}})
}

// 10. 获取用户列表
// http://127.0.0.1:3000/admin/userlist
export const userListFunc = (data={})=>{
    // 获取用户的token
    // let token:string | null | any  = localStorage.getItem('AUTO_TOKEN')
    return axios.get(`${HOST_URL}/admin/userlist`,{params: data , headers:{token}})
}

// 11.0 删除导航
// http://127.0.0.1:3000/admin/delete
export const deleteUserFunc = (data={})=>{
    return axios.post(`${HOST_URL}/admin/delete`,data,{headers:{token}})
}

// 12. 发布文章
// http://127.0.0.1:3000/article/add
export const addArticleFunc = (data={})=>{
    return axios.post(`${HOST_URL}/article/add`,data,{headers:{token}})
}

// 13. 文章列表
// http://127.0.0.1:3000/article/list
export const listArticleFunc = (data={})=>{
    return axios.get(`${HOST_URL}/article/list`,{params: data , headers:{token}})
}
// 14. 删除文章
// http://127.0.0.1:3000/article/remove
export const removeArticleFunc = (data={})=>{
    return axios.post(`${HOST_URL}/article/remove`,data,{headers:{token}})
}
// 15. 获取管理员的头像
// http://127.0.0.1:3000/admin/get_picUrl
export const getAdminPicUrl = (data={})=>{
    return axios.get(`${HOST_URL}/admin/get_picUrl`,{params: data , headers:{token}})
}
// 16. 获取登录地址
// http://127.0.0.1:3000/city/location?ip=113.66.99.71
export const getCurrentLocation = (data={ip: '113.66.99.71'})=>{
    return axios.get(`${HOST_URL}/city/location`,{params: data , headers:{token}})
}
// 17. 统计用户数量
// 地址：http://127.0.0.1:3000/admin/count
export const getUserCount = (data={})=>{
    return axios.get(`${HOST_URL}/admin/count`,{params: data , headers:{token}})
}

















// 假数据
export const fetchData = () => {
    return axios({
        url: './table.json',
        method: 'get'
    });
};


